<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>WebmanAdmin</title>
    <meta name="keywords" content="FAKE Framework"/>
    <meta name="description" content="FAKE is a lightweight php framework."/>
    <meta name="author" content="tianji">
    <meta name="renderer" content="webkit">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <!-- icon -->
    <link rel="icon" type="image/x-icon" href="/static/admin/icon.png">
    <!-- css -->
    <link rel="stylesheet" media="screen" href="/static/admin/login/css/style.css">
    <link rel="stylesheet" media="screen" href="/static/admin/layui/css/layui.css">
	<link rel="stylesheet" href="/static/admin/login/css/index.css">
</head>

<body>
<div class="loginbox">
    <div>
        <fieldset class="layui-elem-field layui-field-title">
            <legend>欢迎登录</legend>
        </fieldset>
        <form class="layui-form layui-form-pane" action='/admin/login/checkLogin'>
            <div class="layui-form-item">
                <label class="layui-form-label">用户账号:</label>
                <div class="layui-input-inline">
                    <input type="username" name="username" value="admin" required="required" lay-verify="username" placeholder="请输入用户" autocomplete="off" class="layui-input">
                </div>
                <i class="layui-icon layui-icon-user" style="font-size: 30px; color: #1E9FFF;"></i>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">用户密码</label>
                <div class="layui-input-inline">
                    <input type="password" name="password" value="123456" required="required" lay-verify="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
                </div>
                <i class="layui-icon layui-icon-password" style="font-size: 30px; color: #1E9FFF;"></i>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">验证码:</label>
                <div class="layui-input-inline" style="width: 120px;">
                    <input type="text" name="captcha" placeholder="输入验证码" class="layui-input">
                </div>
                <img width="140px" height="35px" class="yzm-img" style="border:1px solid #4444" src="/admin/login/captcha" title="点击刷新" alt="验证码">
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid"  lay-submit lay-filter="login">立即登录</button>
            </div>
        </form>
        <p style="padding: 10px; ">
            <a style="float: left;" href="#">立即注册?</a>
            <a style="float: right;" href="#">忘记密码?</a>
        </p>
    </div>
</div>

<!-- particles.js container -->
<div id="particles-js"></div>

<!-- scripts -->
<script src="/static/admin/login/particles.min.js"></script>
<script src="/static/admin/login/js/app.js"></script>
<script src="/static/admin/layui/layui.js"></script>
<script>
    layui.use(['jquery','layer', 'form'], function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        $(".yzm-img").click(function(){
            console.log('刷新验证码');
            this.src = "/admin/login/captcha?"+Math.random();
        });

        //表单submit监听
        form.on('submit(login)', function(data){
            var action = $('.layui-form').attr('action');
            var ary = data.field;

            console.log('login',action,ary)

            $.ajax({
                url: action,
                data: ary,
                type: "post",
                dataType:'json',
                success:function(res){
                    console.log(res);
                    //数据处理
                    if(res.code===1){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function (index) {
                            window.location.href = res.data.url;
                        });
                    } else {
                        layer.msg(res.msg, {icon:2,time:1000});
                    }
                },error: function(res){
                    console.log(res);
                    layer.msg('致命错误');
                }
            });
            return false;
        });

        form.render();
    });
</script>
</body>
</html>